Subject: Optimising_E
From: [email-masked] (Son Huu Le)
To: [email-masked]
Date: Mon, 12 Jul 93 22:35:50 EST

(Profiler output and drool deleted :)

Boyerm.e probably suffered from a low buffer size input, which reminds me,
what are the proper arguments for the DOS function SetVBuf()? The DOS
manual says it accepts 4 arguments, E only accepts 3!?

Okay, so the boyerm.e example wasn't a very good as it relied on DOS calls,
but I still say E is slower and would benefit from a good optimizer. While
I was debugging my programs, I noticed that E always(?) used MOVE.L x(A5),D0
for variable storage/retrieval. In a tight loop, a MOVE.L x(AN),D0
will cost more cycle time than a MOVE.L D1,D0. Since E doesn't touch the
other data registers often, it would help speed time greatly if you could
use them.

For a better example(?) I coded the following short |ittle program, which is
small and relies on no external calls (except for outputting of result at
the end which btw, if left out under SAS/C, makes the program run under
1 sec - clever optimiser :)

E:

PROC main()
DEF x=0, y=0
	WHILE x<500000
		x++
		y:=y+x
	ENDWHILE
	WriteF('\d\n',y)
ENDPROC

Disassembly of main loop:
loop:
	MOVE.L	-4(A5),D0
	CMPI.L	#500000,D0
	BGE	out
	MOVE.L	-4(A5),D0	; What's this for?! (;
	ADDQ.L	#1,-4(A5)
	MOVE.L	-8(A5),D0
	ADD.L	-4(A5),D0
	MOVE.L	D0,-8(A5)
	BRA	loop

C:

#include <stdio.h>

void main()
{
	int x=0, y=0;		/* Direct port - bare minimum change */
	while (x<500000) {
		x++;
		y=y+x;
	}
	printf("%d\n",y);
}

Disassembly of main loop:
loop:
	ADDQ.L	#1,D7
	ADD.L	D7,D6		; SAS/C might be expensive, but look at this!
	CMPI.L	#500000,D7
	BLT.S	loop

Time results:
~~~~~~~~~~~~
(On an Amiga 2000 with 2mb fast, 1mb chip)
(Faster machines might need to alter the counter for meaningful results)

11.STAT-RAM:> timex test_c
446198416
Ticks:429 -> Secs:8.58 -> Time:0h0m8s

11.STAT-RAM:> timex test_e
446198416
Ticks:1224 -> Secs:24.48 -> Time:0h0m24s

Although I don't expect E to outperform a commercial C product, using
spare data registers would increase E's performance tremendously.

One last suggestion.. how about making some E functions (such as WriteF)
more assembling friendly, so you can use certain E functions in the middle
of an assembly code? ie. it uses only the upper data/address registers (4-7)
and leaves the lower ones intact.

Regards..
Son Le

PS. Wouter, your address <[email-masked]> bounced.